<template>
	<view class="">
		<nav-bar title="地址编辑"></nav-bar>
		<van-address-edit :address-info="address" :area-list="areaList" show-delete 
			:area-columns-placeholder="['请选择', '请选择', '请选择']" @save="onSave"
			@delete="onDelete"  />

	</view>
</template>

<script>
	const Address = uniCloud.importObject("address");
	import { areaList } from '@vant/area-data';
	export default {
		setup() {
			return {
				areaList,
			};
		},
		data(){
			return{
				address:{}
			}
		},
		onLoad(o){
			Address.get(o.id).then(res=>{
				// console.log(res);
				this.address = res.data[0]
				this.address.addressDetail = this.address.detail
			})
		},
		methods:{
			onSave(){},
			onDelete(){},
			onSave(e){
			    Address.save(e._id,{
			     name: e.name,
			     tel: e.tel,
			     province: e.province,
			     city: e.city,
			     area: e.county,
			     detail: e.addressDetail,
			    }).then(res=>{
			    })
			   },
			   onDelete(e){
			    Address.delete(e._id).then(res=>{
			    })
			   }
		}
	};
</script>

<style>
</style>
